from django.urls import path

from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView
from .views import *
from rest_framework import routers
from django.urls import path, include
from rest_framework import permissions

router = routers.DefaultRouter()

# redoc
schema_view = get_schema_view(
    openapi.Info(
        title="超灵活框架",
        default_version='v1',
        description="Test description",
        terms_of_service="https://www.google.com/policies/terms/",
        contact=openapi.Contact(email="contact@myapi.local"),
        license=openapi.License(name="BSD License"),
    ),
    public=True,
    permission_classes=[permissions.AllowAny, ],
)

router.register('Modules', ModuleView, basename='应用管理')  # 应用管理
router.register('Menus', MenusView, basename='菜单管理')  # 菜单管理
router.register('User', UsersView, basename='用户管理')  # 用户管理
router.register('Grop', GropView, basename='组管理')
router.register('UserGrop', UserGropView, basename='用户组管理')
router.register('Institutions', InstitutionsView, basename='岗位管理')
router.register('Classification', ClassificationView, basename='用户管理分类')
router.register('InstitutionsTypes', InstitutionsTypesView, basename='岗位类型')
router.register('InstitutionsSelects', InstitutionsSelectsView, basename='岗位类型选择')
router.register('Permissions', MenusPermissionsView, basename='权限管理')
router.register('Flow', FlowView, basename='流程管理')
router.register('images', ImagesView, basename='图片上传接口')
router.register('admdivcode', AdmDivCodeView, basename='区划管理')
router.register('DataBase', DataBaseView, basename='数据库管理')

urlpatterns = [

    path('login/', Login.as_view(), name='login'),
    path('swagger/', schema_view.with_ui('swagger', cache_timeout=120), name='schema-swagger-ui'),
    path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
    path('', include(router.urls)),  # 注册drf viewSets路由
]
